﻿<%@ page contentType="text/html;charset=UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Login</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" /><link href="../demo.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
    body
    {
        width:100%;height:100%;margin:0;overflow:hidden;
    }
     .errorText
    {
        color:red;
    }
    </style>
    <script src="scripts/boot.js" type="text/javascript"></script>
    
    <script language="javascript">  
		function myReload() {  
		    document.getElementById("CreateCheckCode").src = document  
		            .getElementById("CreateCheckCode").src  
		            + "?nocache=" + new Date().getTime();  
		}  
	</script>  
</head>
<body >   
<div id="loginWindow" class="mini-window" title="用户登录" style="width:320px;height:180px;" 
   showModal="true" showCloseButton="false" >
    <div id="loginForm" style="padding:15px;padding-top:10px;">
        <table> 
            <tr> 
                <td style="width: 60px;"><label for="username$text">帐号：</label></td> 
                <td> 
                    <input name="userName" id="userName" errormode="none" onvalidation="onUserNameValidation" required="true" class="mini-textbox" requirederrortext="帐号不能为空" />   
                </td>     
                 <td id="userName_error" class="errorText"><br /></td> 
            </tr> 
            <tr> 
                <td style="width: 60px;"><label for="pwd$text">密码：</label></td> 
                <td> 
                   <input name="password" id="password" errormode="none" onvalidation="onPwdValidation" class="mini-password" required="true" vtype="minLength:5" requirederrortext="密码不能为空" minlengtherrortext="密码不能少于5个字符" />       
                </td> 
                <td id="password_error" class="errorText"><br /></td> 
            </tr>  
            </table><blockquote>
            <table>            
            <tr> 
            	<td width="180"></td> 
                <td style="padding-top: 5px;"> 
                    <a onclick="onLoginClick" class="mini-button" style="width: 60px;">登录</a> 
                </td> 
            </tr> 
        </table>
    </div>

</div>
    <script type="text/javascript">
        mini.parse();
        var loginWindow = mini.get("loginWindow");
        loginWindow.show();
        function onLoginClick(e) {
            var form = new mini.Form("#loginWindow");
            form.validate();
            if (form.isValid() == false) return;
            loginWindow.hide();
            mini.loading("登录成功，马上转到系统...", "登录成功");
            var data = form.getData();
            var json = mini.encode(data);
            $.ajax({
                url: "/ios/pages/User/login.do",
                type: "post",
                data:{submitData:json},
                success:function (text){
                     var o = mini.decode(text);
                     if(o.state)
                     	window.location = "/ios/pages/User/login2.do";
                     else{ 	
                        alert("账号密码错误"); 
                        loginWindow.show();  
                     } 
                },
                error: function (jqXHR, textStatus, errorThrown) {
			         alert("请求出错了!");
			    }
            });
        }
        
        //////////////////////////////////////////
        function updateError(e) {
            var id = e.sender.name + "_error";
            var el = document.getElementById(id);
            if (el) {
                el.innerHTML = e.errorText;
            }
        }
        function onUserNameValidation(e) {                  
            updateError(e);
        }
        function onPwdValidation(e) {        
            updateError(e);
        }
    </script>

</body>
</html>